<?php
require_once 'Datatype_string.php';

/**
 * Datatype for Y-tunnus
 * 
 * @package EDO
 * @subpackage Datatypes
 *
 */
class Datatype_fi_ytunnus extends Datatype_string 
{
	protected $_SQLValueIsQuoted = true;
	
	function validate($validate)
	{
		if(!$this->notNull() AND (is_null($validate) OR $validate == ''))
			return null;
		
		$pattern = "/^\d{7}-\d$/si";
				
		if(parent::validate($validate) AND preg_match($pattern, $validate))
			return $validate;
		
		return false;
		
	}
	
	
	
}
?>